package com.minesweeper.tools;

import com.minesweeper.data.GameData;
import com.minesweeper.ui.GameInterface;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author skniy
 */
public class TimerListener implements ActionListener {

    /**
     * 游戏界面
     */
    private GameInterface gameInterface;

    /**
     * 构造方法
     *
     * @param gameInterface
     */
    public TimerListener(GameInterface gameInterface) {
        this.gameInterface = gameInterface;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        //时间加一
        GameData.TIME_COUNT++;
        //超过999后时间不变
        int maxTime = 999;
        if (GameData.TIME_COUNT > maxTime) {
            GameData.TIME_COUNT = 999;
        }
        //设置时间
        gameInterface.getFunctionPanel().setTime(GameData.TIME_COUNT);
    }
}
